<?php
namespace Admin\Controller;
use Think\Controller;
class SpecController extends CommonController {
    public function add(){
        $goods_type=D('goods_type')->select();
        $this->assign('goods_type',$goods_type);
        if(IS_POST){
            $item=explode(',',i('post.spec_item'));
            $spec_item=array();
            foreach ($item as $key => $v) {
                $spec_item[]['name']=$v;
                # code...
            }
            $_POST['spec_item']=$spec_item;
            $res=D('spec')->relation(true)->add(I('post.'));

             if($res){
            $this->success('新增成功', 'lists');die;
            } else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
                $this->error('新增失败');}die;
        }
        $this->display();
    }
    //列表
    public function lists(){
         // $list=D('Banner')->join('my_banner_point on my_banner.point_id = my_banner_point.id ')->field('my_banner.*,my_banner_point.name')->where($where)->select();
        //$list=D('banner')->relation('true')->where($where)->select();
        $list=D('spec')->relation(true)->select();
        //print_r($list);die;
        $this->assign('list',$list);
        $this->display();
    }
    //编辑
    public function edit(){
        $this->display();
    }
    public function add_point(){
        if(IS_POST){
            $_POST['up_time']=strtotime(I('post.up_time'));
            $_POST['down_time']=strtotime(I('post.down_time'));
            $res=D('banner_point')->add(I('post.'));
            if($res){
            $this->success('新增成功', 'point_list');die;
            } else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
                $this->error('新增失败');}die;
        }

        $this->display();
    }
     public function spec_list(){
        $spec_id=i('get.spec_id');
        $list=D('spec_item')->relation(true)->where("spec_id=$spec_id")->select();
        //print_r($list);die;

        $this->assign('list',$list);
        $this->display();
    }

}